//
//  HomeViewController.m
//  Recycling
//
//  Created by jzd on 2018/5/16.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "HomeViewController.h"

@interface HomeViewController ()
@property (strong, nonatomic) UIImageView *bgImage;
@property (strong, nonatomic) UIScrollView *scrllV;
@end

@implementation HomeViewController

-(UIScrollView *)scrllV{
    if (_scrllV == nil) {
        _scrllV = [[UIScrollView alloc]initWithFrame:self.view.bounds];
        _scrllV.contentSize = self.view.bounds.size;
        _scrllV.backgroundColor = [UIColor whiteColor];
        _scrllV.showsVerticalScrollIndicator = NO;
        _scrllV.showsHorizontalScrollIndicator = NO;
        if (@available(iOS 11.0, *)) {
            _scrllV.contentInsetAdjustmentBehavior =  UIScrollViewContentInsetAdjustmentNever;
        } else {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        CGFloat tabbarH = iphoneX?83:49;
        _scrllV.contentInset = UIEdgeInsetsMake(statsBarHeight+NavgationBarH, 0, tabbarH, 0);
        [self.view addSubview:_scrllV];
    }
    return _scrllV;
}
-(UIImageView *)bgImage{
    if (_bgImage == nil) {
        _bgImage = [[UIImageView alloc]init];
        [self.scrllV addSubview:_bgImage];
    }
    return _bgImage;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BGCOLOR;
    self.navigationItem.title = @"嗨回收";
    [self setImageToImageView];

//    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
//    NSTimeInterval time=[date timeIntervalSince1970]*1000;// *1000 是精确到毫秒，不乘就是精确到秒
//    NSString *timeString = [NSString stringWithFormat:@"%.0f", time];
//    NSLog(@"%@",timeString);


}
-(void)setImageToImageView{
    NSString *imgPath = [[NSBundle mainBundle] pathForResource:@"home.jpg" ofType:nil];
    UIImage *oldImg = [UIImage imageWithContentsOfFile:imgPath];
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat imgW = SJScreenW;
    CGFloat imgH = SJScreenW * (oldImg.size.height/[UIScreen mainScreen].scale) / (oldImg.size.width/[UIScreen mainScreen].scale);
    self.bgImage.frame = CGRectMake(x, y, imgW, imgH);
    self.bgImage.image = oldImg;
    self.scrllV.contentSize = CGSizeMake(SJScreenW, imgH);
    self.scrllV.contentOffset = CGPointMake(0, -(statsBarHeight+NavgationBarH));
}


@end
